﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestLink2Net.Entities;

namespace TestLink2Net.Bal.Interfaces
{
    public interface ISecurityMaster
    {
        bool ValidateUser(string userName, string password);
        void CreateUser(ref User user);
        bool ChangePasswordQuestionAndAnswer(string applicationName, string username, string password, string newPasswordQuestion, string newPasswordAnswer);
        bool ChangePassword(string applicationName, string username, string oldPassword, string newPassword);
        bool ResetPassword(string username, string newpassword, string passwordAnswer);
        bool ResetPassword(string username, string newpassword);

        void UpdateUser(User modifieduser);

        bool UnlockUser(string username, string ApplicationName);

        string GetUserNameByEmail(string email, string ApplicationName);

        bool DeleteUser(string username, string ApplicationName, bool deleteAllRelatedData);

        int GetNumberOfUsersOnline(string ApplicationName, int p);

        User GetUser(Guid guid, string ApplicationName, bool userIsOnline);

        User GetUser(string username, string ApplicationName, bool userIsOnline);

        UserList GetAllUsers(string ApplicationName, int pageIndex, int pageSize);

        UserList FindUsersByName(string ApplicationName, string usernameToMatch, int pageIndex, int pageSize);

        UserList FindUsersByEmail(string ApplicationName, string emailToMatch, int pageIndex, int pageSize);

        bool IsUserInRole(string ApplicationName, string username, string roleName);

        List<string> GetRolesForUser(string ApplicationName, string username);

        void CreateRole(string ApplicationName, string roleName);

        bool DeleteRole(string ApplicationName, string roleName, bool throwOnPopulatedRole);

        bool RoleExists(string ApplicationName, string roleName);

        List<string> FindUsersInRole(string ApplicationName, string roleName, string usernameToMatch);

        List<string> GetAllRoles(string ApplicationName);

        List<string> GetUsersInRole(string ApplicationName, string roleName);

        void AddUsersToRoles(string ApplicationName, string[] usernames, string[] roleNames);

        void RemoveUsersFromRoles(string ApplicationName, string[] usernames, string[] roleNames);
    }
}
